from selenium import webdriver


def create_chrome_driver(headless=False):
    options = webdriver.ChromeOptions()
    if headless:
        options.add_argument('--headless')
    options.add_experimental_option('excludeSwitches', ['enable-automation'])
    options.add_experimental_option('useAutomationExtension', False)
    browser = webdriver.Chrome(options=options)
    browser.maximize_window()
    browser.execute_cdp_cmd(
        'Page.addScriptToEvaluateOnNewDocument',
        {
            'source': 'Object.defineProperty(navigator, "webdriver", {get: () => undefined})'
        }
    )
    return browser


def get_cookies_dict():
    cookies_str = 'bid=ScCwmRvLWmY; _pk_id.100001.4cf6=c60b05da76435fd0.1709607069.; __yadk_uid=8sJSE6Dt9Br2j5IejKpIUOgLMMu4wntJ; __utmc=30149280; __utmz=30149280.1709607070.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=223695111; __utmz=223695111.1709607070.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ll="118282"; ap_v=0,6.0; __utma=30149280.1966215020.1709607070.1709618872.1709623995.3; __utmb=30149280.0.10.1709623995; __utma=223695111.378059494.1709607070.1709618872.1709623995.3; __utmb=223695111.0.10.1709623995; _pk_ses.100001.4cf6=1; _vwo_uuid_v2=DACF958221E3FE864F94AA8330356A0FD|4dc5c820a7ea788f455d4bc73f2c7c81'
    cookies_dict = {}
    for item in cookies_str.split('; '):
        key, value = item.split('=', maxsplit=1)
        cookies_dict[key] = value
    return cookies_dict
